package com.tangbuzhi.chm.ui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.tangbuzhi.chm.R;

/**
 * http://git.oschina.net/tangbuzhi
 *
 * @author Tangbuzhi
 * @version V2.0
 * @Package com.tangbuzhi.chm.ui
 * @Description: ${TODO}
 * @date: 2017/9/11
 */
public class TabFragment extends Fragment {

    private TextView text;

    public static TabFragment newInstance(String title, int color) {
        Bundle bundle = new Bundle();
        TabFragment fragment = new TabFragment();
        bundle.putString("title", title);
        bundle.putInt("color", color);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_tb, container, false);
        text = view.findViewById(R.id.text);
        Bundle arguments = getArguments();
        String title = arguments.getString("title");
        int color = arguments.getInt("color");
        view.setBackground(ContextCompat.getDrawable(getActivity(), color));
        text.setText(title);
        return view;
    }
}
